//
//  DetailVIewViewController.swift
//  NewsAPP
//
//  Created by URNing B on 2021/5/23.
//

import UIKit
import WebKit

class DetailVIewViewController: UIViewController {
    @IBOutlet var NewsWebDetail: WKWebView!
    
    var showValue : AddCollectionNews?
    var news: News = News.init(title: "")
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let nav = tabBarController?.viewControllers?[1]as? UINavigationController
        let sectab = nav?.viewControllers.first as? CollectionTableViewController
        
        showValue = sectab
        loadNews(Url: news.path)
        // Do any additional setup after loading the view.
    }
    
    func loadNews(Url:String)
    {
        NewsWebDetail = WKWebView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height))
        let NewsUrl = URL(string: Url)
        let request = URLRequest(url: NewsUrl!)
        NewsWebDetail.load(request)
        print("显示")
        self.view.addSubview(NewsWebDetail)
    }
    
    @IBAction func CollectButtonPressed(_ sender: Any) {
        print("收藏")
        DBControl.collectNews(news: news)
        CollectionTableViewController.init().viewDidLoad()
        DBControl.GetCollectionNews()
        showValue?.addNews()
    }
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
